#include <faker/engine/Generator.h>

using namespace Faker;

int Faker::Engine::Generator::Generate(Faker::Scene &inst)
{
    Math::Random random;
    const int num = 20;
    glm::vec3 pos[num];
    glm::vec3 rot[num];
    glm::vec4 color[num];

    random.GetVec3(pos, num, glm::vec3(-20.0f), glm::vec3(20.f));
    random.GetVec3(rot, num, glm::vec3(-90.0f), glm::vec3(90.f));
    random.GetVec4(color, num, glm::vec4(0.0f), glm::vec4(1.0f));

    for (int i = 0; i < num; i++)
    {

        Faker::Entity newInst = inst.Create();
        auto &uuid = newInst.AddOrReplaceComponent<Faker::Basic::Uid::Inst>();

        auto &info = newInst.AddOrReplaceComponent<Faker::Basic::Info::Inst>("Cube " + std::to_string(i));

        auto &transform = newInst.AddOrReplaceComponent<Faker::Basic::Transform::Inst>();
        transform.world.position = pos[i];
        // GUT_LOGI("pos is %f %f %f", pos[i].x, pos[i].y, pos[i].z);
        transform.world.rotation = rot[i];

        auto &mat = newInst.AddOrReplaceComponent<Faker::Render::Material::SimpleColor::Inst>();
        mat.mColor = color[i];

        auto &meshBox = newInst.AddOrReplaceComponent<Faker::Render::Mesh::Box::Inst>();
        
    }

    return true;
}